import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项
import echarts from "@/components/machineNetworkManage/pressDataMonitor/echarts.vue"; //弹框form
import customDialog from "@/components/commonPublic/processVideo/index.vue"; //弹框form

import {
    getTestRebarjointtestByFid, //详情
} from "@/api/testMonitorManage/request.js";
export default {
    props: [
        "dialogVisible",
        "dialogTitle",
        "statusNum",
        "currentRow",
        "tableTitle",
        "flagNum"
    ], 
    data() {
        return {
            visible: "",
            loading:false,
            // 过程视频弹框
            processVideoRow: {},
            processVideoShow: false,
            title: null,
            isLock: false,
            dialogHeight: null,
            formObj: formJs.formObj,
            currentDetail: null,
            tableObj: [{
                    lable: "样品编号",
                    value: "fSamplenostr",
                    key:"",
                    row: "50%"
                },
                {
                    lable: "试验日期",
                    value: "fTestdates",
                    key:"",
                    row: "50%"
                },
               
                {
                    lable: "牌号",
                    value: "fBrand",
                    key:"",
                    row: "50%"
                },
                {
                    lable: "公称直径",
                    value: "fDiameter",
                    key:"",
                    row: "50%"
                },
                
                {
                    lable: "工程部位及用途",
                    value: "fProjectlocation",
                    key:"",
                    row: "100%"
                },


            ],
            tableData: [{
                lable: "试件编号",
                value: "fTestid",
                key:"",
                row: "33%"
            },{
                lable: "荷载(kN)",
                value: "fKlhz",
                key:"",
                row: "33%"
            },{
                lable: "强度(MPa)",
                value: "fKlqd",
                key:"",
                row: "33%"
            }],
            echartsData:null,
            formData:null
        };
    },
    components: {
        publicForm,
        echarts,
        customDialog
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },
        statusNum: {
            handler(newVal) {
                if (newVal) {
                    console.log(newVal);
                }
                console.log(888, this.formObj);
            },
            immediate: true,
        },

        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                    if (this.statusNum != 1) {
                        this.getDetail({
                            fId: this.currentDetail.fId
                        })
                    } 
                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("monitorBack-userInfo"));
        if (this.statusNum == 7) { //查看

        }
        this.getHeight();
    },
    methods: {
        processVideoClose() {
            this.processVideoShow = false;
        },
        processVideo() {
            this.processVideoShow = true;
            // window.open(this.formDataVideo.fVideo, '_blank')
        },
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 1 + "px";
        },
        handleSelect(key) {
            this.activeIndex = key;
        },
        closeDialog() {
            this.$emit("close");
        },
        // 详情
        getDetail(obj) {
            this.loading=true;
            getTestRebarjointtestByFid(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading=false;
                    var data = res.data.yjQmpTestRebarjointtest
                    this.tableObj.map(item=>{
                        var name=item.value
                      item['key'] = data[name]
                    })
                    this.formData=res.data
                   this.formDataVideo=res.data.yjQmpTestRebarjointtest
                    this.echartsData=res.data.yjQmpTestRebarjointtestitems
                   
                }else {
                    this.loading=false;
                    this.$message.error(res.msg);
                }
            });
        },


    },
};